/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Prestashop_saver;

import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 *
 * @author strokyl
 */
@Embeddable
public class PsCartProductPK implements Serializable {
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "id_cart", nullable = false)
    private PsCart cart;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "id_product", nullable = false)
    private PsProduct product;

    public PsCartProductPK() {
    }

    public PsCartProductPK(PsCart cart, PsProduct product) {
        this.cart = cart;
        this.product = product;
    }

    public PsCart getCart() {
        return cart;
    }

    public void setCart(PsCart cart) {
        this.cart = cart;
    }

    public PsProduct getProduct() {
        return product;
    }

    public void setProduct(PsProduct product) {
        this.product = product;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PsCartProductPK other = (PsCartProductPK) obj;
        if (this.cart != other.cart && (this.cart == null || !this.cart.equals(other.cart))) {
            return false;
        }
        if (this.product != other.product && (this.product == null || !this.product.equals(other.product))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 67 * hash + (this.cart != null ? this.cart.hashCode() : 0);
        hash = 67 * hash + (this.product != null ? this.product.hashCode() : 0);
        return hash;
    }


}
